package xdu.lz.stage2_design_pattern.chapter18_active_object_pattern;

public class FutureResult implements Result {

    private Result result;

    private boolean ready = false;

    private  synchronized void setResult(Result result){
        this.ready = ready;
        this.ready = true;
        this.notifyAll();
    }
    @Override
    public Object getResultValue() {
        while (!ready){
            try {
                this.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        return this.result;
    }
}
